fix(tracing): Discard invalid navigation transactions via event processor#6051
Merged
fix(tracing): Discard invalid navigation transactions via event processor#6051
Conversation
…ssor
Previously, the SDK discarded "invalid" navigation/interaction root spans
(empty back-navigations, route-change transactions that never received route
info, childless idle transactions, and the latest navigation span on RN
Navigation / React Navigation timeouts) by mutating the private `_sampled`
flag on the SentrySpan. This caused @sentry/core to treat the transactions
as sampled-out, producing misleading "dropped due to sampling" debug logs
and incorrect client-report reasons even when `tracesSampleRate=1.0`.
Switch to a proper event-processor-based discard:
- Mark the root span with a new `sentry.rn.discard_reason` attribute
(`empty_back_navigation`, `no_route_info`, `no_child_spans`, or
`discarded_latest_navigation`) and end it normally with its real sampling
decision.
- The `reactNativeTracingIntegration` event processor now filters out any
transaction event carrying that attribute, returning `null` and reporting
`recordDroppedEvent('event_processor', 'transaction')`.
- The app start integration's lock-reset check looks for the discard marker
instead of `!spanIsSampled`, so app start data still attaches to the next
real transaction after a discarded one.
Tests cover the four discard sites, the event processor (drop / pass /
non-transaction passthrough), and update the existing `_sampled`-based
expectations to assert the new attribute and that the sampling flag is
preserved.
Refs: #4431
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit da56af8. Configure here.
antonis
reviewed
Apr 28, 2026
antonis
reviewed
Apr 28, 2026
antonis
reviewed
Apr 28, 2026
Contributor
antonis
left a comment
There was a problem hiding this comment.
Thank you for your work on this! Overall looks good. I've left some comments along with the cursor findings.
Strengthen types (SentryDiscardReason, EventHint), remove double-counting recordDroppedEvent call (core already records event_processor drops automatically when processor returns null), and fix lost app-start data when the first transaction is discarded by skipping app-start attach when the discard marker is present.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

📢 Type of change
📜 Description
Fixes #4431
Our SDK was previously discarding the "invalid" root spans by changing
_sampledtofalsewhich was a bit of a hack. This PR switches to proper handling instead with the following changes:sentry.rn.discard_reasonattribute;reactNativeTracingIntegrationevent processor now filters out any transaction event with this attribute, returningnulland callingrecordDroppedEvent('event_processor', 'transaction').!spanIsSampled, so app start data still attaches to the next real transaction after a discarded one.💚 How did you test it?
A few tests has been added.
📝 Checklist
sendDefaultPIIis enabled🔮 Next steps